#[allow(unused_imports)]
use std::fmt::Debug;

use reqwest;
use std::path;
use std::time::Duration;
use time;

use futures::executor::block_on;
use tokio::time::sleep;

fn test_df() {
    println!("Hello, world!");
    let sp = time::get_time();
    let s = sp.sec;
    let tm = time::now();
    let tf = tm.asctime();
    let ft = tm.strftime("%y-%m-%d %H:%M:%S").unwrap();

    println!("{}  now={}  ==>{}", s, tf.to_string(), ft);
    let p = path::Path::new("./123/3456/789/");
    let ab_path = p.to_str().unwrap();
    let p_name = p.to_path_buf();
    let is_dir = p.is_dir();
    print!(">>>{}  >>{:?}  is_dir={} ", ab_path, p_name, is_dir);
    let ex = p.try_exists();
    match ex {
        Ok(_) => {
            println!("create file  ok");
        }
        Err(_) => {
            println!("create file  error");
        }
    }
}

async fn hello_world() {
    sleep(Duration::from_secs(3)).await;
    println!("hello, world!");
}
fn test_on() {
    let future = hello_world(); // Nothing is printed
    block_on(future); // `future` is run and "hello, world!" is printed
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // let body = reqwest::get("https://www.rust-lang.org")
    //     .await?
    //     .text()
    //     .await?;
    // println!("body = {:?}", body);
    // sleep(Duration::from_millis(1000)).await;
    test_on();
    Ok(())
}
